package com.woniu.config;

import com.woniu.job.EquipmentMaintenanceJob;
import org.quartz.*;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class QuartzConfig {
    /**
     * 设备维护提醒Job
     * Cron: 每天凌晨2点执行
     */
    @Bean
    public JobDetail equipmentMaintenanceJob() {
        return JobBuilder.newJob(EquipmentMaintenanceJob.class)
                .withIdentity("equipmentMaintenanceJob", "equipmentGroup")
                .storeDurably()
                .build();
    }

    @Bean
    public Trigger equipmentMaintenanceTrigger() {
        return TriggerBuilder.newTrigger()
                .withIdentity("equipmentMaintenanceTrigger", "equipmentGroup")
                .forJob(equipmentMaintenanceJob())
                .withSchedule(CronScheduleBuilder.cronSchedule("0 0 10 * * ?")) // 每天凌晨2点
                .build();
    }
}
